package com.jindy.module.oacopy.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jindy.module.oacopy.domain.SyOaCopy;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.oacopy.service.ISyOaCopyService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 抄送Controller
 * 
 * @author jindy
 * @date 2023-05-12
 */
@RestController
@RequestMapping("/activiti/OaCopy")
public class SyOaCopyController extends BaseController
{
    @Autowired
    private ISyOaCopyService syOaCopyService;

    /**
     * 查询抄送列表
     */
    @PreAuthorize("@ss.hasPermi('activiti:OaCopy:list')")
    @GetMapping("/list")
    public TableDataInfo list(SyOaCopy syOaCopy)
    {
        startPage();
        List<SyOaCopy> list = syOaCopyService.selectSyOaCopyList(syOaCopy);
        return getDataTable(list);
    }

    /**
     * 导出抄送列表
     */
    @PreAuthorize("@ss.hasPermi('activiti:OaCopy:export')")
    @Log(title = "抄送", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SyOaCopy syOaCopy)
    {
        List<SyOaCopy> list = syOaCopyService.selectSyOaCopyList(syOaCopy);
        ExcelUtil<SyOaCopy> util = new ExcelUtil<SyOaCopy>(SyOaCopy.class);
        util.exportExcel(response, list, "抄送数据");
    }

    /**
     * 获取抄送详细信息
     */
    @PreAuthorize("@ss.hasPermi('activiti:OaCopy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(syOaCopyService.selectSyOaCopyById(id));
    }

    /**
     * 新增抄送
     */
    @PreAuthorize("@ss.hasPermi('activiti:OaCopy:add')")
    @Log(title = "抄送", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SyOaCopy syOaCopy)
    {
        return toAjax(syOaCopyService.insertSyOaCopy(syOaCopy));
    }

    /**
     * 修改抄送
     */
    @PreAuthorize("@ss.hasPermi('activiti:OaCopy:edit')")
    @Log(title = "抄送", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SyOaCopy syOaCopy)
    {
        return toAjax(syOaCopyService.updateSyOaCopy(syOaCopy));
    }

    /**
     * 删除抄送
     */
    @PreAuthorize("@ss.hasPermi('activiti:OaCopy:remove')")
    @Log(title = "抄送", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(syOaCopyService.deleteSyOaCopyByIds(ids));
    }
}
